import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// RSA加密
// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDhY9ZawMXhFOQscTYBZYLjtisOFCdIiPFRHHzqesSr1owtqIXfs5gPNtPEnpPBr3/2Ta+brElNWHfcN22rcBefx+otRFLOCPPJwwfO9YWTMy5t4ZYZHgRU3Ck30b/fxvdYHm6qzlvp736wqyEKUOotM9KEh/hGzm88hnVfMmyYMQIDAQAB'

const privateKey = 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAOFj1lrAxeEU5CxxNgFlguO2Kw4UJ0iI8VEcfOp6xKvWjC2ohd+zmA8208Sek8Gvf/ZNr5usSU1Yd9w3batwF5/H6i1EUs4I88nDB871hZMzLm3hlhkeBFTcKTfRv9/G91gebqrOW+nvfrCrIQpQ6i0z0oSH+EbObzyGdV8ybJgxAgMBAAECgYB7BHzoh7L5SOfJAfmSBY/NLY6OXp2aT3Q26y+a42sYxz83ZHW9RU7Hbwtik5Ld8iYLjxc8Bmrz1keFYJNxMPsS6lXCjM4RIl2gpngW8cKGpiGinSrkXVKmOXPgSiN6PjaeADV/CRCoNMdr8jllXr0xrjfxmQOV6/JVtADcPOExSQJBAPLNpIgPHA2o8vSIVtgbHJYgLT4kmnjQp88DspQ5gW6CVW0kUsAOQTnhDcQ7BBA50qfQQIYB74YA51g9UMF5UesCQQDto+gPdyOWC9oGyc3l1vVBkzFJ1+I9AWGIHVW7r+7Fzq8jQmtrEox8pmfJ/Vgj5mnWjqB3lWNETotpoYg5SdtTAkEAm7PqPeJKoCvm2Y+Q+XaxZ0htGvvIH4/W/PcnDsytxttHwvzXIBhEFcTP2jXqTil2gG0Y45bcLjfoI3r2jYuqTwJBANc0tjU7OXjqprm7C8F3V4fZGqu62+FPXNn9ZuSfwOZV9HlD7y96DsvbjuZ3jdiFE5gAdgWVvd3gG5S/ejQXVI0CQCcFunoX1O8O9O7PtvA/WE6y0cd88A+BE8SwozUjQ4wsZAawrya0pJ9YnGZED1e3FPKrW1cIsn2fPKLqUfj8Xo0='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

